﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using S.Eartag.Domain.Model;
using S.Eartag.Domain;
using S.Eartag.Read.API.Application.Command.SheepFileConditionCommand;
using PublicClass;
using S.Eartag.Infrastructure.Impl;
using S.Eartag.Infrastructure.Interface;

namespace S.Eartag.Read.API.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class SheepFileController : ControllerBase
    {
        private readonly IMediator mediator;

        public SheepFileController(IMediator mediator)
        {
            this.mediator = mediator;
        }


        /// <summary>
        /// 羊只档案
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<PageInfoS<SheepFile>> SheepFileConditionGet([FromQuery] SheepFileConditionGetCommand request)
        {
            return await mediator.Send(request);
        }
        /// <summary>
        /// 性别下拉
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<List<object>> SheepFileConditionSex([FromQuery] SheepFileConditionSexCommand request)
        {
            return await mediator.Send(request);
        }
        /// <summary>
        /// 生长阶段
        /// </summary>
        /// <returns></returns>
        /// 
        [HttpGet]
        public IActionResult GetGrowthStage()
        {
            List<object> list = new List<object>();
            foreach (var item in Enum.GetValues<GrowthStage>())
            {
                list.Add(new
                {
                    name = item.ToString(),
                    value = item
                });
            }
            return Ok(list);
        }
        /// <summary>
        /// 羊只类型
        /// </summary>
        /// <returns></returns>
        /// 
        [HttpGet]
        public IActionResult GetGrowthSheepType()
        {
            List<object> list = new List<object>();
            foreach (var item in Enum.GetValues<SheepType>())
            {
                list.Add(new
                {
                    name = item.ToString(),
                    value = item
                });
            }
            return Ok(list);
        }
        /// <summary>
        /// 基因等级
        /// </summary>
        /// <returns></returns>
        /// 
        [HttpGet]
        public IActionResult GetGeneClass()
        {
            List<object> list = new List<object>();
            foreach (var item in Enum.GetValues<GeneClass>())
            {
                list.Add(new
                {
                    name = item.ToString(),
                    value = item
                });
            }
            return Ok(list);
        }
        /// <summary>
        /// 生产等级
        /// </summary>
        /// <returns></returns>
        /// 
        [HttpGet]
        public IActionResult GetProductionGrade()
        {
            List<object> list = new List<object>();
            foreach (var item in Enum.GetValues<ProductionGrade>())
            {
                list.Add(new
                {
                    name = item.ToString(),
                    value = item
                });
            }
            return Ok(list);
        }
        /// <summary>
        /// 销售等级
        /// </summary>
        /// <returns></returns>
        /// 
        [HttpGet]
        public IActionResult GetSalesGrade()
        {
            List<object> list = new List<object>();
            foreach (var item in Enum.GetValues<SalesGrade>())
            {
                list.Add(new
                {
                    name = item.ToString(),
                    value = item
                });
            }
            return Ok(list);
        }
        /// <summary>
        /// 繁殖状态
        /// </summary>
        /// <returns></returns>
        /// 
        [HttpGet]
        public IActionResult GetReproductiveState()
        {
            List<object> list = new List<object>();
            foreach (var item in Enum.GetValues<ReproductiveState>())
            {
                list.Add(new
                {
                    name = item.ToString(),
                    value = item
                });
            }
            return Ok(list);
        }
        /// <summary>
        /// 在场状态
        /// </summary>
        /// <returns></returns>
        /// 
        [HttpGet]
        public IActionResult GetPresence()
        {
            List<object> list = new List<object>();
            foreach (var item in Enum.GetValues<Presence>())
            {
                list.Add(new
                {
                    name = item.ToString(),
                    value = item
                });
            }
            return Ok(list);
        }
        /// <summary>
        /// 反填种公种母后裔信息
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<SheepFile> SheepFileConditionFind([FromQuery] SheepFileConditionFindCommand request)
        {
            return await mediator.Send(request);

        }
        /// <summary>
        /// 耳号反填
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<SheepFile> SheepFileConditionFinds([FromQuery]SheepFileConditionFindsCommand request)
        {
            return await mediator.Send(request);
        }
        /// <summary>
        /// 档案耳号
        /// </summary>
        /// <param name="request"></param>
        [HttpGet]
        public async Task<List<SelectList>> SheepFileConditionEard([FromQuery]SheepFileConditionEardCommand request)
        {
            return await mediator.Send(request);
        }
        [HttpGet]
        public async Task<DTO> SheepFileConditionbreed([FromQuery]SheepFileConditionbreedCommand request)
        {
            return await mediator.Send(request);
        }
        /// <summary>
        /// 全部档案
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<List<ArchivesDTO>> SheepFileConditionarchives([FromQuery]SheepFileConditionarchivesCommand request)
        {
            return await mediator.Send(request);
        }
        [HttpGet]
        public async Task<SheepFile> SheepFileConditionarprogeny([FromQuery]SheepFileConditionarprogenyCommand request)
        {
            return await mediator.Send(request);
        }
        [HttpGet]
        public async Task<List<SheepFile>> SheepFileConditionarFemale([FromQuery]SheepFileConditionarFemaleCommand request)
        {
            return await mediator.Send(request);
        }
        /// <summary>
        /// 返回所有后裔信息
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<List<SheepFile>> SheepFileConditionarDescendantfile([FromQuery]SheepFileConditionarDescendantfileCommand request)
        {
            return await mediator.Send(request);
        }

        /// <summary>
        /// 没有条件的所有档案信息
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        /// 
        [HttpGet]
        public async Task<List<SheepFile>> SheepFileConditionarown([FromQuery]SheepFileConditionarownCommand request)
        {
            return await mediator.Send(request);
        }
    }
}
